import PublicApi from "@/api/form/core/public";
import FormCodegenBusinessApi from "@/api/form/codegen/formCodegenBusiness";

export default {
    data() {
        return {
            //数据来源(选项)
            businessSourceList: [],
            //数据来源(对象)
            businessSourceMap: {}
        }
    },
    methods: {
        initBusinessSourceList() {
            var self = this;
            PublicApi.getFormCodegenBusinessSources().then(res => {
                if (!res) {
                    return;
                }
                self.businessSourceList = res.map(item => {
                    return {value:item.key,label:item.name};
                });
                self.businessSourceList.forEach(item => {
                    self.businessSourceMap[item.value] = item.label;
                })
            })
        },
        reloadBusinessColumns(paramter, callback) {
            FormCodegenBusinessApi.reloadColumns(paramter).then(res => {
                if (callback && res.success) {
                    callback(res);
                }
            })
        }
    }
}